package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    void add(Orders orders);

    Page<Orders> page(OrdersPageQueryDTO ordersPageQueryDTO);

    Orders getById(Long id);

    void cancel(Orders orders);

    void payment(Orders orders);

    Orders getByOrderNumber(String orderNumber);

    Integer countStatus(Integer status);

    void adminCancel(Orders orders);

    void confirm(OrdersConfirmDTO ordersConfirmDTO);

    void rejection(Orders orders);

    void updateStatus(Orders orders);

    List<Orders> getByStatusAndOrderTime(Integer status, LocalDateTime orderTime);

    Double getTurnover();

    Integer countOrder();

    Double getAmountByDateAndStatus(@Param("date") LocalDate localDate,
                                    @Param("status") Integer completed);

    /**
     * 获取订单数
     * @param localDate 日期
     * @param status 状态
     * @return 订单数
     */
    Integer getCountByDateAndStatus(@Param("date") LocalDate localDate,
                                    @Param("status") Integer status);

    Integer countByMap(LocalDateTime begin,LocalDateTime end,Integer status);

    Double sumByMap(LocalDateTime begin,LocalDateTime end,Integer status);
}